﻿using System;
using System.Collections.Generic;
using System.Linq;

using ExtensibleEventViewer.Console.Views;
using ExtensibleEventViewer.Core.Primitives;


namespace ExtensibleEventViewer.Console.Presenters
{
	internal class EventLogListPresenter : PresenterBase<IEventLogListView>
	{
		public EventLogListPresenter(IEventLogListView view)
			: base(view)
		{
		}

		public void LoadData()
		{
			IEnumerable<EventLogEntity> eventLogs = Enumerable.Empty<EventLogEntity>();

			try
			{
				eventLogs = View.Connector.GetEventLogList();
			}
			catch (Exception ex)
			{
				HandleException(ex);
			}

			View.EventLogEntities = new List<EventLogEntity>(eventLogs);
		}
	}
}
